import { Color, Vec2 } from "cc";
import { Cell } from "./Cell";

/**
 * 用于生成房间时候的临时存储和计算
 */
export class TmpRoom{
    public id:number;
    //Room左上角的Cell，用于定位
    public anchorRow:number;
    public anchorCol:number;
    public upRow:number;
    public downRow:number;
    public leftCol:number;
    public rightCol:number;
    public width:number;
    public height:number;
    public cells:Array<Cell> = [];
    public oriAnchor:Cell;
    //受力情况
    public stressUp:number;
    public stressDown:number;
    public stressLeft:number;
    public stressRight:number;
    public TmpRoomType:number;
    public stressCenterRow:number;
    public stressCenterColumn:number;
    public inertia:Vec2;
    public overlapRooms:Array<TmpRoom>;

    //杂项
    public roomColor:Color;

    constructor(){
        this.clearStress();
    }

    public clearStress(){
        this.inertia = null;
        this.stressUp = 0;
        this.stressDown = 0;
        this.stressLeft = 0;
        this.stressRight = 0;
    }

    public addOverlapRoom(room:TmpRoom){
        if(!this.overlapRooms.includes(room)){
            this.overlapRooms.push(room);
        }
    }

    public clearOverlapRooms(){
        this.overlapRooms = [];
    }
}